home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Browser Speed / WebWarper.exe / HTML / 131 < prev    next >
Encoding:
Text File  |  2001-05-04  |  3.0 KB  |  100 lines

  1. <script language="VBScript">
  2.  
  3. function correctLink(a)
  4.     correctLink = a
  5.     if InStr(1, a, "http://siams.com/ww.pl", 1) = 1 then exit function
  6.     if InStr(1, a, "http://siams.com/wwl.pl", 1) = 1 then exit function
  7.     if InStr(1, a, "http://siams.com:", 1) = 1 then
  8.         if InStr(1, a, "/ww.pl", 1) <> 0 then exit function
  9.         if InStr(1, a, "/wwl.pl", 1) <> 0 then exit function
  10.     end if
  11.     correctLink = "http://siams.com/ww.pl?~GZ/" & Right(a, Len(a)-7)
  12. end function 
  13.  
  14. function openLink(srcAnchor)
  15.     if not (TypeName(srcAnchor) = "HTMLAnchorElement" or TypeName(srcAnchor) = "HTMLAreaElement") then
  16.         openLink = False
  17.         exit function
  18.     end if
  19.     openLink = True
  20.     set l = srcAnchor
  21.     a = "" & l.href
  22.     if Left(a, 1) = "/" then
  23.         a = "http://" & external.menuArguments.document.location.host & a
  24.     end if
  25.     if InStr(a, "http://") = 1 then
  26.         window.open correctLink(a), "_blank"
  27.     else
  28.         alert "Sorry, WebWarper is not applicable for this page. " & Chr(13) _
  29.             & "It is viewed through the """ & l.protocol _
  30.             & """ protocol," & Chr(13) & "but WebWarper can be used only with " _
  31.             & "pages viewed" & Chr(13) & "through the ""http://"" protocol."
  32.     end if
  33. end function
  34.  
  35. sub openImg(src)
  36.     a = "" & src
  37.     if Left(a, 1) = "/" then
  38.         a = "http://" & external.menuArguments.document.location.host & a
  39.     end if
  40.     if InStr(a, "http://") = 1 then
  41.         window.open correctLink(a), "_blank"
  42.     else
  43.         alert "Sorry, WebWarper is not applicable for this page. " & Chr(13) _
  44.             & "It is viewed through the """ & Left(a, InStr(a, ":")) _
  45.             & """ protocol," & Chr(13) & "but WebWarper can be used only with " _
  46.             & "pages viewed" & Chr(13) & "through the ""http://"" protocol."
  47.     end if
  48. end sub
  49.  
  50. sub OnContextMenu()
  51.     set srcEvent = external.menuArguments.event
  52.     set EventElement = srcEvent.srcElement    
  53.     if TypeName(EventElement) = "Nothing" then
  54.         set EventElement = external.menuArguments.document.elementFromPoint(srcEvent.clientX, srcEvent.clientY)
  55.     end if
  56.  
  57.     if srcEvent.type = "MenuExtAnchor" then 
  58.         set srcAnchor = EventElement
  59.         do until TypeName(srcAnchor) = "HTMLAnchorElement"
  60.             set srcAnchor = srcAnchor.parentElement
  61.         Loop
  62.         openLink(srcAnchor)
  63.         exit sub
  64.     end if
  65.  
  66.     if srcEvent.type = "MenuExtImage" then
  67.         if TypeName(EventElement) = "HTMLAreaElement" then
  68.             openLink(EventElement)
  69.         else 
  70.             set srcImage = EventElement
  71.             set srcAnchor = srcImage.parentElement
  72.             do until TypeName(srcAnchor) = "HTMLAnchorElement"
  73.                 set srcAnchor = srcAnchor.parentElement
  74.                 if TypeName(srcAnchor) = "Nothing" then 
  75.                     openLink(srcImage)
  76.                     exit sub
  77.                 end if
  78.             Loop
  79.             openLink(srcAnchor)
  80.         end if
  81.         exit sub
  82.     end if
  83.  
  84.     if srcEvent.type = "MenuExtUnknown" then
  85.         set srcAnchor = EventElement
  86.         do until TypeName(srcAnchor) = "Nothing"
  87.             if openLink(srcAnchor) then exit sub
  88.             set srcAnchor = srcAnchor.parentElement
  89.         Loop
  90.         if TypeName(EventElement) = "HTMLImg" then
  91.             openImg EventElement.src
  92.             exit sub
  93.         end if
  94.     end if
  95. end sub
  96.  
  97. OnContextMenu()
  98.  
  99. </script>
  100.